const { override, addWebpackAlias, fixBabelImports, addLessLoader, adjustStyleLoaders } = require("customize-cra");
const path = require("path");

/* const editEntry = entry => config => {
  const newConfig = {
    ...config,
    entry: path.join(__dirname, entry)
  };
  console.log("config参数", newConfig);
  return newConfig;
}; */

module.exports = override(
  // 添加alias别名
  addWebpackAlias({
    "@": path.resolve(__dirname, "./src")
  }),
  // 按需引入antd样式
  fixBabelImports("import", {
    libraryName: "antd",
    libraryDirectory: "es",
    style: true
  }),
  addLessLoader({
    // 改变less变量需要先删除下node_modules
    lessOptions: {
      javascriptEnabled: true,
      modifyVars: { "@primary-color": "#1DA57A", "border-radius-base": "5px" }
    }
  }),
  adjustStyleLoaders(({ use: [, , postcss] }) => {
    const postcssOptions = postcss.options;
    postcss.options = { postcssOptions };
  })
  // editEntry("./src/pages/miniReact/index.js") // 引入手动写的miniReact
);
